import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:get/get.dart';
import 'package:jinke/utils/component/component.dart';
import 'package:jinke/utils/util.dart';

import '../../pro_list/subs/pro_detail/subs/pro_instruction/model/ProInstruction.dart';
import '../controller.dart';

class InstructionCell extends StatelessWidget {
  InstructionCell(this.index);
  int index;
  final controller = Get.find<InstructController>();


  @override
  Widget build(BuildContext context) {
    ProInstruction proInstruction = controller.state.lists[index];
    return GestureDetector(
      onTap: (){
        Get.toNamed(RouterPath.instruction_detail,arguments: {"project":proInstruction});
      },
      child: Container(
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(4.r),
        ),
        margin: EdgeInsets.fromLTRB(16.r, 16.r, 16.r, 0),
        child: Padding(
          padding: EdgeInsets.fromLTRB(16.r, 16.r, 16.r, 0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                proInstruction.projectAlias??'',
                style: TextStyle(
                  color: ColorsUtil.title,
                  fontSize: 16.r,
                  fontWeight: FontWeight.bold,
                ),
              ),
              SizedBox(
                height: 10.r,
              ),
              separatorLine(),
              SizedBox(
                height: 10.r,
              ),
              Row(
                children: [
                  loadAvater(size: 40.r),
                  SizedBox(
                    width: 10.r,
                  ),
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        proInstruction.directiveUserName??'',
                        style: TextStyle(
                          color: ColorsUtil.title,
                          fontSize: 16.sp,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      SizedBox(height: 10.r,),
                      Text(
                        (proInstruction.tagDate??'')+'\t\t'+(proInstruction.tagTime??''),
                        style: TextStyle(
                          color: ColorsUtil.content,
                          fontSize: 12.r,
                        ),
                      ),
                    ],
                  ),
                ],
              ),
              Container(
                padding: EdgeInsets.symmetric(vertical: 10.r),
                child: Html(
                  data: proInstruction.directiveContent??'',
                  style: {
                    'code':Style(
                        color: ColorsUtil.blue
                    )
                  },
                ),
              ),
              separatorLine(),
              TitleContentItemView(title: '查看详情')
            ],
          ),
        ),
      ),
    );
  }
}
